$def with (settings)

<script type="text/javascript">
$$(document).ready(function() {
    $$( "#tabs" ).tabs();
    $$("#save-config").click(function() {
        $$.post( "/ajax", { 
            'func': "save_file",
            'filename': "/etc/cura/"+$$("#txt-save-config-as").val(),
            'content': $$("#txt-config").val()
        }).done(function( data ) {
            highlight(data.ok, "#txt-config");
        });
    });

    $$("#save-printer").click(function() {
        $$.post( "/ajax", { 
            'func': "cura_choose_config",
            'filename': $$("#printer-config").val()
        }).done(function( data ) {
            $$("#txt-config").val(data.new_config)
            $$("#txt-save-config-as").val(data.new_name)
            highlight(data.ok, "#txt-config");
            highlight(data.ok, "#printer-config");
        });
    });

});



function highlight(ok, id){
    if(ok){
        $$(id).effect( "highlight", 
            {color:"green"}, 1000 );
    } else {
        $$(id).effect( "highlight", 
            {color:"red"}, 1000 );
    }
}
</script>



<h1>Configure the Cura Slicer</h1>
<div id="tabs">
    <ul>
        <!--<li><a href="#tabs-1">Visual</a></li>-->
        <li><a href="#tabs-2">Text based</a></li>
    </ul>
    <div id="tabs-2">
        <h3>Select Cura config</h3>
        <p>Choose which printer you have. You can make changes to it.</p>
        printer.ini -> <select id="printer-config" autocomplete="off">
            $for file in settings["printers"]["all"]:
                $if file == settings["printers"]["current"]["name"]:
                    <option value="$file" selected="1">$file</option>
                $else:
                    <option value="$file">$file</option>
        </select> 
        <button type="button" id="save-printer">Select</button>
        <h3>Cura config</h3>
        <textarea id="txt-config" style="width: 100%; height: 400px;">$settings["config"]</textarea>
        <span>Save config as</span>
        <input type="textfield" id="txt-save-config-as" value='$settings["printers"]["current"]["name"]'></input>
        <button type="button" id="save-config">Save</button>
        <p>If you are saving to a different name, refresh this page after to update the list.</p>
    </div>
</div>








